﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp.Buttons
{
    public partial class ToggleButtonDemo : Window, IWindow
    {
        public ToggleButtonDemo()
        {
            InitializeComponent();
            this.button3.Checked += new EventHandler(button3_Checked);
            this.button3.Unchecked += new EventHandler(button3_Unchecked);
            this.button3.Indeterminate += new EventHandler(button3_Indeterminate);

            this.checkBox1.Checked += new RoutedEventHandler(checkBox1_Checked);
            this.checkBox1.Unchecked += new RoutedEventHandler(checkBox1_Unchecked);
        }

        void checkBox1_Unchecked(object sender, RoutedEventArgs e)
        {
            if (this.button3 == null)
                return;

            this.button3.IsThreeState = false;
            this.radioButton3.IsEnabled = false;
        }

        void checkBox1_Checked(object sender, RoutedEventArgs e)
        {
            if (this.button3 == null)
                return;

            this.button3.IsThreeState = true;
            this.radioButton3.IsEnabled = true;
        }

        void button3_Indeterminate(object sender, EventArgs e)
        {
            if (this.radioButton3 == null)
                return;

            this.radioButton3.IsChecked = true;
            this.button3.Text = "Indeterminate State";
        }

        void button3_Unchecked(object sender, EventArgs e)
        {
            if (this.radioButton2 == null)
                return;

            this.radioButton2.IsChecked = true;
            this.button3.Text = "Toggled Off";
        }

        void button3_Checked(object sender, EventArgs e)
        {
            if (this.radioButton1 == null)
                return;

            this.button3.Text = "Toggled On";
            this.radioButton1.IsChecked = true;
        }

        private void radioButton3_Checked(object sender, RoutedEventArgs e)
        {
            if (this.button3 == null)
                return;

            if (this.button3.IsThreeState)
            {
                this.button3.IsChecked = null;
            }
        }

        private void radioButton2_Checked(object sender, RoutedEventArgs e)
        {
            if (this.button3 == null)
                return;

            this.button3.IsChecked = false;
        }

        private void radioButton1_Checked(object sender, RoutedEventArgs e)
        {
            if (this.button3 == null)
                return;

            this.button3.IsChecked = true;
        }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        public void SetTheme()
        {
        }

        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }   
    }
}
